<?php

namespace app\api\controller;

use app\common\model\User;

class AuthController extends DefaultController
{
    function loginAction(){
        $username = $this->request->param('username');
        if(empty($username)){
            return $this->responseJson("用户名不能为空");
        }

        $password = $this->request->param('password');
        if(empty($password)){
            return $this->responseJson("密码不能为空");
        }

        $user = User::find()->getOne();

        $data = array();
        $data['code'] = 222;
        $data['message'] = '';

        $result = array();
        /*$result["id"] = "234l324l23l4l23l4l32l";
        $result["name"] = "weiyi";
        $result["username"] = "admin";
        $result["password"] = "";
        $result["avatar"] = "https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png";
        $result["status"] = 1;
        $result["telephone"] = "";
        $result["lastLoginIp"] = "27.154.74.117";
        $result["lastLoginTime"] = "1534837621348";
        $result["creatorId"] = "admin";
        $result["createTime"] = "1534837621348";
        $result["lastLoginTime"] = "1497160610259";
        $result["deleted"] = 0;
        $result["roleId"] = "admin";
        $result["lang"] = "zh-CN";*/
        $result["token8"] = "4291d7da9005377ec9aec4a71ea837f";

        $data['result'] = $result;
        $data['method'] = $this->request->method();
        $data['param'] = $this->request->param();
        $data['post'] = file_get_contents("php://input");

        return $this->responseJson($data);
    }

    function logoutAction(){
        $data = array();
        $data['message'] = '';
        echo json_encode($data,JSON_UNESCAPED_UNICODE);
        exit();
    }
}